package day017.homework.p4;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Scanner;

public class Test {
    private static final Logger log = LoggerFactory.getLogger(Test.class);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String name = sc.nextLine();
        System.out.println("请输入密码：");
        String pwd = sc.nextLine();

        try {
            login(name, pwd);
        } catch (LoginException e) {
            System.out.println(e.getMessage());
        }
    }

    public static void login(String name, String pwd) {
        if (!(name.equals("admin"))) {
            throw new LoginException("用户名不存在！");
        }
        if (!(pwd.equals("admin"))) {
            throw new LoginException("密码错误！");
        }

        System.out.println("欢迎" + name + "!");
    }
}
